﻿<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <title>用户登录</title>
  <link rel="stylesheet" type="text/css" href="/static/index/css/pc-jifen-login.d09e1d82.css">
  <link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css">
  <script src="/static/layer/jquery.min.js"></script>

  <script src="/static/layer/layer.js"></script>
</head>
<body>
<div class="content">
  <div class="content-wrapper cf">
    <div class="login-container independent-password">
      <div class="login-box second-login-box">
        <div style="border: 2px solid #eee;height:376px; width: 376px; " >
          <div class="site-text site-block">
            <div class="title" id="title_2" style="font-size: 18px;text-align: center;margin-top: 30px;">帐号密码登录</div>
            <form style="margin-top: 2em">
              <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                  <input type="text" id="uname" name="uname"  required=""  placeholder="用户名"  class="layui-input" style="width: 200px;">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                  <input type="password"  id="upwd" name="upwd"   required=""  placeholder="密码" class="layui-input" style="width: 200px;">
                </div>
              </div>
              <div class="layui-form-item" style="margin-top: 20px;">
                <div class="layui-input-block">
                  <button class="layui-btn layui-btn-fluid" onclick="login()" type="button" style="width: 200px;">登陆</button>
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
    <div class="login-pictures">
      <div class="logo">
        <a href="{:url('user/Login/register')}">
          <img src="/static/index/picture/login.png" alt="PHPmall" width="50">
        </a>

      </div>

    </div>
  </div>
</div>
<div class="footer login">
  <div class="footer_cont">
    <p><span class="copyright">Copyright © 2018 王恒兵</span></p>
  </div>
</div>

<script type="text/javascript" src="/static/layui/layui.js" charset="UTF-8"></script>

<script>

    function login() {
        // 用户名
        var uname = $("#uname").val();
        var upwd = $("#upwd").val();
        var uPattern = /^[a-zA-Z0-9_-]{5,16}$/;
        var pass = /^\w{6,16}$/;
        if(!uPattern.test(uname)){
            layer.msg('用户名不正确', {
                icon: 5,
                skin: 'layer-ext-moon'
            });
            return;
        }
        if(upwd=='' || !pass.test(upwd)){
            layer.msg('请输入6-16位密码', {
                icon: 5,
                skin: 'layer-ext-moon'
            });
            return;
        }

        var url = "{:url('user/Login/HandleLogin')}";
        var postData ={"uname":uname,"upwd":upwd};
        $.post(url,postData,function (result) {
            if(result.error === 1 ){
                layer.msg(result.msg);
                location.href = "/";
            }else {
                layer.msg(result.msg, {
                    icon: 5,
                    skin: 'layer-ext-moon'
                });

            }
        },"json")

    }

</script>
</body>
</html>
